let s = "hello world"
var lengthOfLastWord = function(s) {
    let index = s.length-1
    let add = 0
    while(s[index]==" "&&index>=0){
        index--
        
        
    }
    while(s[index]!==" "){
        index--
        add++ 
    }
    return add
};

lengthOfLastWord(s)